Fix read response handling and add configurable read timeout - #75
Open
AlexanderTonn wants to merge 4 commits into
Open
Fix read response handling and add configurable read timeout#75AlexanderTonn wants to merge 4 commits into
AlexanderTonn wants to merge 4 commits into
Conversation
…nt 1000ms is blocking the mcu to much if a lot of values have to be read
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request improves the read handling of the EasyNextionLibrary and makes the timeout used by the read functions configurable.
Changes
Added the new public method:
void setReadTimeout(uint32_t timeout);Replaced the different hard-coded timeout values inside readNumber() and readStr() with the configurable _readTimeout value.
Motivation
The original implementation uses several fixed timeout values of up to 1000 ms while waiting for responses from the Nextion display.
When multiple values are read sequentially, especially in applications where the MCU also has to perform other time-critical tasks, these fixed timeouts can cause unnecessary blocking.
The new setReadTimeout() method allows the application to select a timeout appropriate for its communication setup. For example:
myNex.setReadTimeout(100);
This can significantly reduce the maximum blocking time when a Nextion response is missing or invalid, while keeping the existing 1000 ms timeout as the default for backward compatibility.
Compatibility
Existing applications do not need to be modified. If setReadTimeout() is not called, the library continues to use the default timeout of 1000 ms.